﻿using System;
using System.Collections.Generic;

namespace GiveAQuiz.Data
{
  /// <summary>
  /// This intereface exposes the CRUD methods for Quizzes
  /// in the underlying data storage.
  /// </summary>
  public interface IQuizRepository
  {
    /// <summary>
    /// Gets a listing of Quizzes for a given User.
    /// </summary>
    /// <param name="userKey">The user to search for.</param>
    /// <returns>An Enumeration of QuizDefinition objects 
    /// for the specified User.</returns>
    IEnumerable<QuizDefinition> GetUserQuizDefinitions(Guid userKey);

    /// <summary>
    /// Retrieve a QuizDefinition from the underlying data storage
    /// by the specified id.
    /// </summary>
    /// <param name="quizDefinitionId">The id of the QuizDefinition 
    /// to retrieve.</param>
    /// <returns>The corresponding QuizDefinition object.</returns>
    QuizDefinition GetQuizDefintion(int quizDefinitionId);

    /// <summary>
    /// Retrieve a Quiz from the underlying data storage
    /// by the specified id.
    /// </summary>
    /// <param name="quizId">The id of the Quiz to retrieve.</param>
    /// <returns>The corresponding Quiz object.</returns>
    Quiz GetQuiz(int quizId);
    
    /// <summary>
    /// Retrieves a Quiz from the underlying data storage
    /// by its passphrase.
    /// </summary>
    /// <param name="passphrase">The passphrase to search on.</param>
    /// <returns>The corresponding Quiz object if found; otherwise null.</returns>
    Quiz GetQuizByPassphrase(string passphrase);

    /// <summary>
    /// Save a QuizResult in the underlying data storage.
    /// </summary>
    /// <param name="quizResult">The result to save.</param>
    void SaveQuizResult(QuizResult quizResult);

    /// <summary>
    /// Retrieve a QuizResult from the underlying data storage
    /// by the specified id.
    /// </summary>
    /// <param name="quizResultId">The id of the QuizResult to 
    /// retrieve.</param>
    /// <returns>The corresponding QuizResult object.</returns>
    QuizResult GetQuizResult(int quizResultId);

    /// <summary>
    /// Save a QuizUser in the underlying data storage.
    /// </summary>
    /// <param name="user">The user to save.</param>
    void SaveUser(QuizUser user);

    /// <summary>
    /// Save a Quiz in the underlying data storage.
    /// </summary>
    /// <param name="quiz">The Quiz to save.</param>
    void SaveQuiz(Quiz quiz);

    /// <summary>
    /// Updates a Quiz in the underlying data storage.
    /// </summary>
    /// <param name="quiz">The quiz to update.</param>
    void UpdateQuiz(Quiz quiz);

    /// <summary>
    /// Delete a Quiz from the underlying data storage by the
    /// specified id.
    /// </summary>
    /// <param name="id">The id of the Quiz to delete.</param>
    void DeleteQuiz(int id);

    /// <summary>
    /// Delete a QuizDefinition from the underlying data storage by the
    /// specified id.
    /// </summary>
    /// <param name="id">The id of the QuizDefintion to delete.</param>
    void DeleteQuizDefinition(int id);

    /// <summary>
    /// Delete all the results for a given Quiz.
    /// </summary>
    /// <param name="quizId">The ID of the Quiz.</param>
    void DeleteQuizResults(int quizId);
  }
}
